<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:gml="http://www.opengis.net/gml" 
	xmlns:ogr="http://ogr.maptools.org/"
	xmlns:ramon_geo="http://ec.europa.eu/eurostat/ramon/ontologies/geographic.rdf#" 
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
	
<xsl:output method="text" indent="yes" />
	
<xsl:template match="/ogr:FeatureCollection">
	
	<xsl:result-document href="id/index.ttl">
@prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
@prefix nuts: &lt;http://nuts.geovocab.org/id/&gt; .

nuts:index rdfs:seeAlso nuts:nuts0 .
nuts:index rdfs:seeAlso nuts:nuts1 .
nuts:index rdfs:seeAlso nuts:nuts2 .
nuts:index rdfs:seeAlso nuts:nuts3 .
	</xsl:result-document>
	
	<xsl:result-document href="id/nuts0.ttl">
		<xsl:call-template name="nuts_index">
			<xsl:with-param name="level" select="0"/>
		</xsl:call-template>
	</xsl:result-document>
	
	<xsl:result-document href="id/nuts1.ttl">
		<xsl:call-template name="nuts_index">
			<xsl:with-param name="level" select="1"/>
		</xsl:call-template>
	</xsl:result-document>
	
	<xsl:result-document href="id/nuts2.ttl">
		<xsl:call-template name="nuts_index">
			<xsl:with-param name="level" select="2"/>
		</xsl:call-template>
	</xsl:result-document>
	
	<xsl:result-document href="id/nuts3.ttl">
		<xsl:call-template name="nuts_index">
			<xsl:with-param name="level" select="3"/>
		</xsl:call-template>
	</xsl:result-document>
	
</xsl:template>

<xsl:template name="nuts_index">
	<xsl:param name="level" />

@prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
@prefix nuts: &lt;http://nuts.geovocab.org/id/&gt; .
	
	<xsl:for-each select='gml:featureMember/ogr:NUTS_RG_60M_2006[ogr:STAT_LEVL_=$level]' >
nuts:nuts<xsl:value-of select="$level"/> rdfs:seeAlso nuts:<xsl:value-of select="ogr:NUTS_ID"/> .
	</xsl:for-each>

</xsl:template>

</xsl:stylesheet>